package org.lex.lang;

import java.io.File;

public class SystemUtils {
	public final static String JAVA_HOME = "java.home";
	public final static String JAVA_IO_TMPDIR = "java.io.tmpdir";
	public final static String LINE_SEPARATOR = "line.separator";
	public final static String USER_DIR = "user.dir";// app start dir
	public final static String USER_HOME = "user.home";// user home dir

	public static File getJavaHome() {
		return getFileProperty(JAVA_HOME);
	}

	public static File getTempDir() {
		return getFileProperty(JAVA_IO_TMPDIR);
	}

	/**
	 * Application startup directory
	 * 
	 * @return
	 */
	public static File getUserDir() {
		return getFileProperty(USER_DIR);
	}

	/**
	 * Current user's root directory
	 * 
	 * @return
	 */
	public static File getUserHome() {
		return getFileProperty(USER_HOME);
	}

	public static String getLineSeparator() {
		return System.getProperty(LINE_SEPARATOR);
	}

	public static File getFileProperty(String propertyName) {
		File file = null;
		String path = System.getProperty(propertyName);
		if (null != path) {
			file = new File(path);
		}
		return file;
	}
}
